package com.xthink.web.controller;

import com.xthink.common.vo.iPackage.CustomPackagePageVo;
import com.xthink.common.vo.iPackage.InsertCustomSpecs;
import com.xthink.common.vo.iPackage.LikeCustomPackage;
import com.xthink.common.vo.iPackage.NewCustomPackageVo;
import com.xthink.common.result.AjaxResult;
import com.xthink.web.service.CustomPackageHistoryService;
import com.xthink.web.service.CustomSpecsHistoryService;
import com.xthink.web.service.PackageService;
import com.xthink.web.service.PackageSpecsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pipPackage")
public class PipPackageController {
    @Autowired
    private PackageService packageService;

    @Autowired
    private PackageSpecsService packageSpecsService;

    @Autowired
    private CustomPackageHistoryService customPackageHistoryService;

    @Autowired
    private CustomSpecsHistoryService customSpecsHistoryService;

    //新建标准套餐
    @PostMapping("/newPipPackage")
    public AjaxResult newPipPackage(@RequestBody NewCustomPackageVo newCustomPackageVo){
        return packageService.newPipPackage(newCustomPackageVo);
    }

    //标准套餐分页查询
    @PostMapping("/pipPackagePage")
    public AjaxResult pipPackagePage(@RequestBody CustomPackagePageVo customPackagePageVo){
        return packageService.pipPackagePage(customPackagePageVo);
    }

    //标准套餐上架
    @GetMapping("/pipPackagePutOn/{ids}")
    public AjaxResult pipPackagePutOn(@PathVariable("ids") Integer[] ids){
        return packageService.pipPackagePutOn(ids);
    }

    //标准套餐下架
    @GetMapping("/pipPackageOff/{ids}")
    public AjaxResult pipPackageOff(@PathVariable("ids") Integer[] ids){
        return packageService.pipPackageOff(ids);
    }

    //删除标准套餐
    @GetMapping("/pipPackageDelete/{ids}")
    public AjaxResult pipPackageDelete(@PathVariable("ids")Integer[] ids){
        return packageService.pipPackageDelete(ids);
    }

    //标准套餐模糊搜索
    @PostMapping("/pipPackageLike")
    public AjaxResult pipPackageLike(@RequestBody LikeCustomPackage likeCustomPackage){
        return packageService.pipPackageLike(likeCustomPackage);
    }

    //标准套餐详情
    @GetMapping("/pipPackageDetails/{id}")
    public AjaxResult pipPackageDetails(@PathVariable("id") Integer id){
        return packageService.pipPackageDetails(id);
    }

    //标准套餐规格详情
    @GetMapping("/pipPackageSpecsDetails/{id}")
    public  AjaxResult pipPackageSpecsDetails(@PathVariable("id") Integer id){
        return packageSpecsService.pipPackageSpecsDetails(id);
    }

    //标准套餐规格上架
    @GetMapping("/pipPackageSpecsPutOn/{ids}")
    public AjaxResult pipPackageSpecsPutOn(@PathVariable("ids") Integer[] ids){
        return packageSpecsService.pipPackageSpecsPutOn(ids);
    }

    //标准套餐规格下架
    @GetMapping("/pipPackageSpecsOff/{ids}")
    public AjaxResult pipPackageSpecsOff(@PathVariable("ids") Integer[] ids){
        return packageSpecsService.pipPackageSpecsOff(ids);
    }

    //修改价格标准套餐规格价格
    @GetMapping("/pipPackageSpecsUpdatePrice/{id}/{price}")
    public AjaxResult pipPackageSpecsUpdatePrice(@PathVariable("id") Integer id,@PathVariable("price") Double price){
        return packageSpecsService.pipPackageSpecsUpdatePrice(id,price);
    }

    //新增标准套餐规格
    @PostMapping("/InsertPipSpecs")
    private AjaxResult insertPipSpecs(@RequestBody InsertCustomSpecs insertCustomSpecs){
        return packageSpecsService.insertPipSpecs(insertCustomSpecs);
    }

    //修改标准套餐单价
    @GetMapping("/pipPackageUpdatePrice/{id}/{price}")
    public AjaxResult pipPackageUpdatePrice(@PathVariable("id") Integer id,@PathVariable("price") Double price){
        return packageService.pipPackageUpdatePrice(id,price);
    }

    //查询标准套餐单价历史价格
    @PostMapping ("/listPipPackagePrice")
    public AjaxResult listPipPackagePrice(@RequestBody CustomPackagePageVo customPackagePageVo){
        return customPackageHistoryService.listPipPackagePrice(customPackagePageVo);
    }

    //查询标准套餐规格历史价格
    @PostMapping("/listPipSpecsPrice")
    public AjaxResult listPipSpecsPrice(@RequestBody CustomPackagePageVo customPackagePageVo){
        return customSpecsHistoryService.listPipSpecsPrice(customPackagePageVo);
    }
}
